<%@language=vbscript%>
<%
	Session("FormName")=""
	Session("VanBan")=""
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<!--#include file="..\RootContent.inc"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<!--#include file="..\JvGrid.inc"-->
<!--#include file="..\pageSelected.inc"-->
<%
	bComm=Request("bComm")	
	IDFlow=request("TxtMa")
	bDisplay=request("bDisplay")
	bMaflownode=Request("bMaflownode")
	'Duoc goi tu Form Theo doi Flow
	if Request("bXoa")="ok" then
		IDFLow=Request("bIDXoa")
		sSQL="Select * from Workflow Where Maworkflow Like '"& IDFLow &"'"
		Set RecXoaID=server.CreateObject("ADODB.Recordset")
		RecXoaID.CursorType=3
		RecXoaID.CacheSize=5
		RecXoaID.Open sSQL,Conn
		if RecXoaID.RecordCount then
			if not isnull(RecXoaID("NodeCha")) then
				bMaflownode=RecXoaID("NodeCha")				
			else
				bMaflownode=""
			end if
			bComm="delete"
		end if
		RecXoaID.Close
		Set RecXoaID=nothing
	end if
	Select case bComm
		case "delete"
			on error resume next
			Conn.BeginTrans
			if bMaFlownode<>"" then
				sSQL="Update Flownode set maworkflowcon=NULL where maworkflownode like '"& bMaflownode &"'"
				Conn.Execute sSQL
			else
			'Xoa cac FLowcon
				sSQL="Select * from flownode where maworkflow like '"& IDFLow &"'"
				Set RecXcon=server.CreateObject("ADODB.Recordset")
				RecXcon.CursorType=3
				RecXcon.CacheSize=5
				RecXcon.Open sSQL,conn
				do while not RecXcon.EOF
					if not isnull(RecXcon("maworkflowcon")) then
						'bg thphuc 27-01-03 xoa file dinh kem va file noi dung y kien xu ly
						Call DeleteFileNode(RecXcon("maworkflowcon"))
						'ed thphuc 27-01-03 xoa file dinh kem va file noi dung y kien xu ly
						sSQL="Delete from workflow where maworkflow like '"& RecXcon("maworkflowcon") &"'"
						Conn.Execute sSQL
						sSQL="Delete from flownode where maworkflow like '"& RecXcon("maworkflowcon") &"'"
						Conn.Execute sSQL
						Call DeleteFile(RecXcon("maworkflowcon"))
					end if
					RecXcon.MoveNext
				Loop
				RecXcon.Close
				set RecXcon=nothing

			end if
			'bg thphuc 27-01-03 xoa file dinh kem va file noi dung y kien xu ly
			Call DeleteFileNode(IDFlow)
			'ed thphuc 27-01-03 xoa file dinh kem va file noi dung y kien xu ly
			sSQL="Delete from workflow where maworkflow like '"& IDFlow &"'"
			Conn.Execute sSQL			
			sSQL="Delete from flownode where maworkflow like '"& IDFlow &"'"
			Conn.Execute sSQL
			'Xoa van ban
			Call DeleteFile(IDFlow)
			if Err.number=0 then
				Conn.CommitTrans
			else
				Conn.RollbackTrans
			end if			
			sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao Like '"& Session("bMaCB") &"' order by ngaytao DESC"
			sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao = '"& Session("bMaCB") &"' or (workflow.maworkflow in (select IDworkflow from workflow_canbo where Iduser =  '"& Session("bMaCB") &"')) or (workflow.maworkflow in (select maworkflow From workflow where maworkflow in (select maworkflow From flownode where Idnguoitao='"& Session("bMaCB") &"'))) order by ngaytao DESC"
		case "search"
			bTrichyeu=request("TxtTrichyeu")
			bTungay=Request("TxtTungay")
			bDenngay=Request("TxtDenNgay")
			if (bTungay<>"" and bDenNgay<>"") then
				'sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao Like '"& Session("bMaCB") &"'"
				sSQL="SELECT * From workflow WHERE Tam<>1 And ( Ngaytao Between '"& SaveDate(bTungay) &"' And '"& SaveDate(bDenngay) &"') And Nguoitao like '"& Session("bMaCB") &"' And tenvuviec like '%"& Modistring(bTrichyeu) &"%' or (workflow.maworkflow in (select IDworkflow from workflow_canbo where Iduser =  '"& Session("bMaCB") &"')  or (workflow.maworkflow in (select maworkflow From workflow where maworkflow in (select maworkflow From flownode where Idnguoitao='"& Session("bMaCB") &"'))) And tenvuviec like '%"& Modistring(bTrichyeu) &"%') "
				'sSQL=SSQL+" And tenvuviec like '%"& Modistring(bTrichyeu) &"%'"
				'sSQL=sSQL+" And ( Ngaytao Between '"& SaveDate(bTungay) &"' And '"& SaveDate(bDenngay) &"')"
				sSQL=sSQL+" order by ngaytao DESC"
			else
				'sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao Like '"& Session("bMaCB") &"'"
				'sSQL=SSQL+" And tenvuviec like '%"& Modistring(bTrichyeu) &"%'"
				'sSQL=sSQL+" order by ngaytao DESC"
				sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao like '"& Session("bMaCB") &"' And tenvuviec like '%"& Modistring(bTrichyeu) &"%' or (workflow.maworkflow in (select IDworkflow from workflow_canbo where Iduser =  '"& Session("bMaCB") &"')  or (workflow.maworkflow in (select maworkflow From workflow where maworkflow in (select maworkflow From flownode where Idnguoitao='"& Session("bMaCB") &"')))  And tenvuviec like '%"& Modistring(bTrichyeu) &"%') "
				'sSQL=SSQL+" And tenvuviec like '%"& Modistring(bTrichyeu) &"%'"
				sSQL=sSQL+" order by ngaytao DESC"
			end if
		Case else
				'sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao Like '"& Session("bMaCB") &"' order by ngaytao DESC"
				sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao = '"& Session("bMaCB") &"' or (workflow.maworkflow in (select IDworkflow from workflow_canbo where Iduser =  '"& Session("bMaCB") &"')) or (workflow.maworkflow in (select maworkflow From workflow where maworkflow in (select maworkflow From flownode where Idnguoitao='"& Session("bMaCB") &"')))  order by ngaytao DESC"
	end select
	Set Rec=server.CreateObject("ADODB.recordset")
	Rec.CursorType=3
	Rec.CacheSize=5
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	Rec.Open sSQL,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if			
	if  bDisplay then
		'sSQL="SELECT * From workflow WHERE Tam<>1 And Nguoitao Like '"& Session("bMaCB") &"' and maworkflow like '"& request("bMa") &"' order by ngaytao DESC"
		sSQL="SELECT * From workflow WHERE Tam<>1 and maworkflow like '"& request("bMa") &"'  order by ngaytao DESC"
		Set RecDisplay=Server.CreateObject("ADODB.Recordset")
		RecDisplay.CursorType=3
		RecDisplay.CacheSize=5
		RecDisplay.Open sSQL,Conn
		if RecDisplay.RecordCount>0 then
			bMa=RecDisplay("maworkflow")
			bNgayTao=RecDisplay("Ngaytao")
			bTrichyeu=RecDisplay("tenvuviec")
			bTentep=RecDisplay("Tentepxuly")
			bNguoitao=Session("Uname")
			bMaRoot=RecDisplay("Nguoitao")
			nguoitao=RecDisplay("Nguoitao")
			IDFlow=RecDisplay("maworkflow")			
		end if
	end if
	
%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript runat=server>
	' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y
	Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function
	Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
	End function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>	
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ChangePage(){
	strURL=frm.page.value;
	window.frm.target="right";
	window.frm.action=strURL;
	window.frm.submit();
}

function CmdDelete_onclick() {
	if(trim(frm.TxtMa.value)==""){
		alert("Cho biết dòng cần xoá");
		return false;				
	}
	if(!confirm("Bạn có muốn xoá không?")){
	  return false;
	}
	frm.action="frmdsflow.asp?bMaflownode="+"<%=bMaflownode%>"+"&IDFlow="+frm.TxtMa.value+"&bComm=delete&Filename="+"<%=request("filename")%>";
	frm.target="right";
	frm.submit();	
}

function CmdEdit_onclick() {
	if(trim(frm.TxtMa.value)==""){
		alert("Cho biết dòng cần theo dõi");
		return false;				
	}
	
	frm.action="flow.asp?bNotEdit=<%=request("bNotEdit")%>&bTheodoi=ok&IDFlow="+frm.TxtMa.value+"&Nguoitao="+"<%=Nguoitao%>"+"&bMaRoot="+"<%=bMaRoot%>";
	frm.target="right";
	frm.submit();
}

function CmdSearch_onclick() {
	if (frm.TxtTrichyeu.disabled){
		frm.CmdSearch.value="Tì<u>m</u>";
		frm.TxtDenngay.disabled=false;
		frm.TxtTungay.disabled=false;
		frm.TxtTrichyeu.disabled=false;
		frm.TxtDenngay.value="<%=Formatdate(Date())%>";
		frm.TxtTungay.value="<%=Formatdate(Date()-90)%>";
	
		frm.TxtTrichyeu.focus();
		return false;
	}
	if(trim(frm.TxtTungay.value)!=""){
		if (!isDate(frm.TxtTungay.value)){
			alert("Ngày không hợp lệ");
			frm.TxtTungay.focus();
			return false;
		}
	}
	if(trim(frm.TxtDenngay.value)!=""){	
		if (!isDate(frm.TxtDenngay.value)){
			alert("Ngày không hợp lệ");
			frm.TxtDenngay.focus();
			return false;
		}
	}
	window.frm.target="right"
	window.frm.action="frmdsflow.asp?bComm=search";
	window.frm.submit();	
}

function CmdLamtuoi_onclick() {
	window.frm.target="right"
	window.frm.action="frmdsflow.asp";
	window.frm.submit();
}

function CmdCreate_onclick() {
	frm.target="right";	
	switch (frm.ComboLoaiVT.value)
	{
	    case "vtden":
     	   frm.action="../Xuly/frmdsvtden.asp?bfromflow=ok";
	    break
	    case "vtduthao":
			frm.action="../Xuly/frmdsvtduthao.asp?bfromflow=ok";     	   
	    break
	    case "quyetdinh":
			frm.action="../Xuly/frmdsVTQuyetdinh.asp?bfromflow=ok";     	   
	    break
	    case "vtnoibo":
			frm.action="../Xuly/frmdsVTNoibo.asp?bfromflow=ok";     	   
	    break
	    default:
			frm.action="frmTaonguon.asp?bfromflow=ok";
	}		
	frm.submit();
}

function TxtTungay_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	frm.TxtTungay.value=editdate(trim(str))
}
}

function TxtDenngay_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	frm.TxtDenngay.value=editdate(trim(str))
}
}

function SetFocus(){
	window.frm.CmdSearch.focus();
}
//-->
</SCRIPT>
</head>

<body leftmargin=2 topmargin="2" onload="SetFocus()">
<form name=frm method=post target=right>
	<%if bDisplay then%>
		<Input type=hidden name=TxtMa value=<%=bMa%>>
		<Input type=hidden name=TxtNguoitao value=<%=bNguoitao%>>
		<Input type=hidden name=TxtTentep value=<%=bTentep%>>
	<%else%>
		<Input type=hidden name=TxtMa>
		<Input type=hidden name=TxtNguoitao>
		<Input type=hidden name=TxtTentep>
	<%end if%>
	<Input type=hidden name="strURL" value="">
  <table border="0" width="100%" bgcolor="#BDD5D0" cellspacing=0 cellpadding=0>
    <tr>
      <TD WIDTH="100%" COLSPAN="6" BGCOLOR="#000080" ALIGN="CENTER"><FONT face="Arial" COLOR="#FFFFFF" size=2>THEO DÕI XỬ LÝ CÔNG VIỆC</FONT></TD>
    </tr>
    <tr>
      <td width="10%" align="center">Trích yếu</td>
      <td width="30%">
		<%if bDisplay then%>
			<textarea name="TxtTrichyeu" Disabled=true style="font-family: Arial;width:100%" rows=1 cols="20"><%=bTrichyeu%></textarea></td>
		<%else%>
			<textarea name="TxtTrichyeu" Disabled=true style="font-family: Arial;width:100%" rows=1 cols=20></textarea></td>
		<%end if%>
      <td width="13%" align="center">Từ ngày<br>(Ngày tạo)</td>
      <td width="13%">
		<%if bDisplay then%>
			<input type='text' name='TxtTungay' value='<%=FormatDate(bNgaytao)%>' maxLength=10 Disabled=true style="font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtTungay_onkeyup(this.value)" size="20"></td>
		<%else%>
			<input type="text" name="TxtTungay" maxLength=10 Disabled=true style="font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtTungay_onkeyup(this.value)"></td>
		<%end if%>
      <td width="13%" align="center">Ðến ngày<br>(Ngày tạo)</td>
      <td width="13%">
		<%if bDisplay then%>
			<input type="text" name="TxtDenngay" value='<%=FormatDate(bNgaytao)%>' maxLength=10 Disabled=true style="font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtDenngay_onkeyup(this.value)" size="20"></td>
		<%else%>
			<input type="text" name="TxtDenngay" maxLength=10 Disabled=true style="font-family: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtDenngay_onkeyup(this.value)"></td>
		<%end if%>
      </tr>
  </table>
<!-- Buttons -->
<table border="1" width="100%" bgcolor="#BDD5D0" cellspacing="1" cellpadding=0 bordercolorlight="#000000" bordercolordark="#808080">
	<tr>	    
		<td width="22%">
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F28",1)="1" or Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F22",2)="1" or Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F19",8)="1" or Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F21",9)="1" or Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F23",7)="1" or Session("IsAdmin")=true then%>
				<Button language="javascript" name="CmdCreate"  style="font-family: Arial; height: 25; position: relative; width:100%" onclick="return CmdCreate_onclick()" accesskey="T"><p><u>T</u>ạo luồng xử lý từ</p></Button>
			<%else%>
				<Button language="javascript" name="CmdCreate"  style="font-family: Arial; height: 25; position: relative; width:100%" disabled  onclick="return CmdCreate_onclick()" accesskey="a"><p>T<u>ạ</u>o luồng xử lý từ</p></Button>
			<%end if%>
			</td>	  		
	  		<td width="26%">
	  			<select name="ComboLoaiVT" size="1" style="font-family: Arial; height: 23; position: relative; width:100%">
					<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F28",1)="1" or Session("IsAdmin") then%>
						<option selected value='tudo'>Nguồn văn bản tự tạo</option>
					<%end if%>
					<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F22",2)="1" or Session("IsAdmin") then%>
						<option value='vtduthao'>Nguồn văn bản dự thảo</option>
					<%end if%>
					<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F19",8)="1" or Session("IsAdmin") then%>
						<option value='vtden'>Nguồn văn bản đến</option>
					<%end if%>
					<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F21",9)="1" or Session("IsAdmin") then%>
						<option value='quyetdinh'>Nguồn văn bản quyết định</option>
					<%end if%>
					<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F23",7)="1" or Session("IsAdmin") then%>
						<option value='vtnoibo'>Nguồn văn bản nội bộ</option>
					<%end if%>
				</select>
			</td>
		<%if bMa="" then%>
   			<td width="13%"><Button disabled name="CmdEdit" style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
   			<td width="13%"><Button name="CmdDelete" disabled style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
		<%else%>
   			<td width="13%"><Button name="CmdEdit" style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="E"><p>Th<u>e</u>o dõi</p></Button></td>
   			<td width="13%"><Button name="CmdDelete" style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
		<%end if%>
			<td width="13%"><Button name="CmdSearch" style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
   			<td width="13%"><Button name="CmdLamtuoi" style="font-family: Arial; height: 25; position: relative; width:100%" LANGUAGE=javascript onclick="return CmdLamtuoi_onclick()" accesskey="L"><p><u>L</u>àm tươi</p></Button></td>
		</tr>
	</table>
<!-- Danh sach cong viec da tao -->
<table border="0" width="100%" style="border-style: solid;Border-color:#C0C0C0">
  <tr>
	<TD width="100%" COLSPAN="3" BGCOLOR="#000080" ALIGN=CENTER><FONT face="Arial" COLOR=WHITE SIZE=2>
    DANH SÁCH DÒNG CÔNG VIỆC ÐÃ TẠO</FONT></TD>
  </tr>
  <tr bgcolor="#BDD5D0">
    <td width="5%" align="center"></td>  
    <td width="75%" align="center"><b>Chủ đề</b></td>
    <td width="20%" align="center"><b>Ngày tạo</b></td>
    <%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
    %>
    <%if Rec("Maworkflow")=Request("bMa") then
			color="#BDD7D6"
		end if%>
  <tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>" onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
		<%
			sSQL="Select hovaten,username from canbo where macanbo like '"& Rec("Nguoitao") &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset")
			RecTemp.CursorType=3
			RecTemp.CacheSize=5
			RecTemp.Open sSQL,Conn
			if (not RecTemp.EOF) and (not  rectemp.BOF) then
				Nguoitao=RecTemp("username")
				hoten=RecTemp("Hovaten")
			end if
			RecTemp.Close
			Set RecTemp=nothing
			
			sSQL="Select trangthaixl from flownode where maworkflow like '"& Rec("Maworkflow") &"'"
			Set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if RecKT.RecordCount then
				bAll=RecKT.RecordCount
			end if
			red=0
			blue=0
			Do while not RecKT.EOF
				if RecKT("Trangthaixl")=0 or RecKT("Trangthaixl")=-1 then
					Red=Red+1
				end if		
				if RecKT("Trangthaixl")=2 then
					Blue=Blue+1
				end if
				RecKT.MoveNext
			Loop
			RecKT.Close
			Set recKT=nothing
			'bg thphuc 24-02-2003
			sSQL="select trangthai from workflow where maworkflow like '"& Rec("Maworkflow") &"'"
			Set RecKtWorkFlow=server.CreateObject("ADODB.Recordset")
			RecKtWorkFlow.CursorType=3
			RecKtWorkFlow.CacheSize=5
			RecKtWorkFlow.Open sSQL,Conn
			if RecKtWorkFlow.recordcount then
				kttrangthai=RecKtWorkFlow("trangthai")
			end if
			RecKtWorkFlow.close
			set RecKtWorkFlow=nothing
			'ed thphuc 24-02-2003
			if Red=bAll then
				icon="images/THUDO.gif"
			else
				if Blue=bAll then
					'bg thphuc 24-02-2003
					if kttrangthai then
						icon="images/thuxanh.gif" 
					else
						icon="images/vang_xanh.gif" 
					end if
					'ed thphuc 24-02-2003
				else
					icon="images/thuvang.gif"
				end if
			end if
			if trim(Session("bMaCB"))<>trim(Rec("Nguoitao")) then
				bLink="flow.asp?bNotEdit=true&bTheodoi=ok&IDFlow="& Rec("Maworkflow") &"&Nguoitao="& Rec("Nguoitao")  &"&bMaRoot="& Rec("Nguoitao") 
			else
				bLink="flow.asp?bNotEdit=false&bTheodoi=ok&IDFlow="& Rec("Maworkflow") &"&Nguoitao="& Rec("Nguoitao")  &"&bMaRoot="& Rec("Nguoitao") 
			end if
			if not isnull(Rec("NodeCha")) then
				bMaflownode=Rec("NodeCha")
				vuviec=Rec("Tenvuviec") & " (&#208;&#432;&#7907;c t&#7841;o t&#7915; ng&#432;&#7901;i x&#7917; l&#253; )"
			else
				bMaflownode=""
				vuviec=Rec("Tenvuviec")
			end if
			
		%>
		<td width="5%" align=center><a href=<%=bLink%> target=right><Img src=<%=icon%> border=0 title='Theo d&#245;i d&#242;ng c&#244;ng vi&#7879;c'></a></td>
		<%if trim(Session("bMaCB"))<>trim(Rec("Nguoitao")) then%>
			<td width="75%"><%=Vuviec%></td>
			<td width="20%" align=center> <%=formatdate(Rec("Ngaytao"))%></td>	    
		<%else%>
			<td width="75%"><a style='text-decoration: none' href="frmdsflow.asp?bNotEdit=false&bMaflownode=<%=bMaflownode%>&page=<%=npage%>&bDisplay=True&bMa=<%=Rec("Maworkflow")%>&filename=<%=Rec("Tentepxuly")%>" target=right><%=Vuviec%></a></td>
			<td width="20%" align=center><a style='text-decoration: none' href="frmdsflow.asp?bNotEdit=false&bMaflownode=<%=bMaflownode%>&page=<%=npage%>&bDisplay=True&bMa=<%=Rec("Maworkflow")%>&filename=<%=Rec("Tentepxuly")%>" target=right> <%=formatdate(Rec("Ngaytao"))%>&nbsp;<%=Hour(cDate(Rec("Ngaytao")))%>:<%=Minute(cDate(Rec("Ngaytao")))%>:<%=Second(cDate(Rec("Ngaytao")))%></a></td>
		<%end if%>
  </tr>
  <input type="hidden" name="ID<%=STT%>" value="<%=Rec("Maworkflow")%>">
	<%
		if  Session("VanBan")="" then
			Session("VanBan")="-" & Rec("Maworkflow") 
		else
			Session("VanBan")=Session("VanBan") & "-" & Rec("Maworkflow") 
		end if
	%>
  <%		STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
		Session("VanBan")=Session("VanBan") & "-"
	end if
	rec.Close
	set rec=nothing
  %>
</table>
</SCRIPT>
 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
					strURL="frmDsFlow.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm="
				else
					strURL="frmDsFlow.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm=search"
				end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %>            -->  
<% 'else %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
<% end if %>
  </tr>
</table>
</body>
</form>
</html>
<%
	Conn.Close
	Set Conn=nothing
%>
<Script language=vbscript runat=server>
	'Khi xoa 1 workflow thi xoa kem theo File vanban cua Workflow dong thoi xoa danh sach cac file van ban gan kem
	Function DeleteFile(bIDFlow)
		sSQL="Select Tentep from Workflow_Tentep where Maworkflow = '"& bIDFlow &"'"
		Set RecXoa =server.CreateObject("ADODB.Recordset")
		RecXoa.CursorType=3
		RecXoa.CacheSize=5
		RecXoa.Open sSQL,Conn
		set Obj=server.CreateObject("ActiveFile.File")
		Do while not RecXoa.EOF
			Tentep=RecXoa("Tentep")
			obj.Name=RootContent & "Data\Yeucau\" & Tentep
			if obj.Exists() then
				obj.Delete()
			end if
			RecXoa.MoveNext
		Loop
		RecXoa.Close
		Set RecXoa=nothing
		TentepTEXT=bIDFlow & ".VT"
		obj.Name=RootContent & "Data\Yeucau\TEXT\" & TentepTEXT
		if obj.Exists() then
			obj.Delete()
		end if
		sSQL="Delete from workflow_Tentep where maworkflow = '"& bIDFlow &"'"
		Conn.Execute sSQL
		Set Obj=nothing
	End Function
	'bg thphuc 23-01 ham xoa file dinh kem va file noi dung y kien xu ly
	Function DeleteFileNode(bIDFlow)
		'xoa file va data cua file dinh kem
		sSQL="Select maflownode,Tentep from flownode_Tentep where Maflownode like '"& bIDFlow &"%'"
		Set RecXoa =server.CreateObject("ADODB.Recordset")
		RecXoa.CursorType=3
		RecXoa.CacheSize=5
		RecXoa.Open sSQL,Conn
		set Obj=server.CreateObject("ActiveFile.File")
		Do while not RecXoa.EOF
			Tentep=RecXoa("Tentep")
			obj.Name=RootContent & "Data\xuly\" & Tentep
			if obj.Exists() then
				obj.Delete()
			end if
			RecXoa.MoveNext
		Loop
		RecXoa.Close
		Set RecXoa=nothing
		sSQL="Delete from flownode_Tentep where maflownode like '"& bIDFlow &"%'"
		Conn.Execute sSQL
		'xoa file noidung cua y kien xu ly
		sSQL="Select maworkflownode from flownode where Maworkflow like '"& bIDFlow &"'"
		Set RecXoaND =server.CreateObject("ADODB.Recordset")
		RecXoaND.CursorType=3
		RecXoaND.CacheSize=5
		RecXoaND.Open sSQL,Conn
		Do while not RecXoaND.EOF
			TentepTEXT=RecXoaND("maworkflownode") & ".VT"
			obj.Name=RootContent & "Data\xuly\TEXT\" & TentepTEXT
			if obj.Exists() then
				obj.Delete()
			end if
			RecXoaND.MoveNext
		loop
		RecXoaND.Close
		Set RecXoaND=nothing
		Set Obj=nothing
	End Function
	'ed thphuc 23-01 ham xoa file dinh kem va file noi dung y kien xu ly
</Script>